<template>
	<view class="content poRel">
		<view class="wid100 bacFFF">
			<view class="wid80 mar dis disAl" style="justify-content: space-around;height: 160rpx;">
				<view class="textCen" @click="tiaozhuan('/pages/technician/dynamically/praise')">
					<view class="mar poRel" style="width: 65rpx;height: 65rpx;">
						<image src="../../../static/y_gz.png" class="wh100"></image>
						<view v-if="weidu && weidu.click_unread > 0" class="dis disAl disJuC coFFF borRad50 foSi20 poAbs" 
							style="background: #ff0000;width: 30rpx;height: 30rpx; top: -10rpx;right: -10rpx;">{{weidu.click_unread}}</view>
					</view>
					<view class="foSi20 mar-top10">收获的赞</view>
				</view>
				<view class="textCen" @click="tiaozhuan('/pages/technician/dynamically/attention')">
					<view class="mar poRel" style="width: 65rpx;height: 65rpx;">
						<image src="../../../static/y_cz.png" class="wh100"></image>
						<view v-if="weidu && weidu.follow_unread > 0" class="dis disAl disJuC coFFF borRad50 foSi20 poAbs"
							style="background: #ff0000;width: 30rpx;height: 30rpx; top: -10rpx;right: -10rpx;">{{weidu.follow_unread}}</view>
					</view>
					<view class="foSi20 mar-top10">新增关注</view>
				</view>
				<view class="textCen" @click="tiaozhuan('/pages/technician/dynamically/comment')">
					<view class="mar poRel" style="width: 65rpx;height: 65rpx;">
						<image src="../../../static/y_zd.png" class="wh100"></image>
						<view v-if="weidu && weidu.comment_unread > 0" class="dis disAl disJuC coFFF borRad50 foSi20 poAbs"
							style="background: #ff0000;width: 30rpx;height: 30rpx; top: -10rpx;right: -10rpx;">{{weidu.comment_unread}}</view>
					</view>
					<view class="foSi20 mar-top10">收获的评论</view>
				</view>
			</view>
		</view>
		<scroll-view style="height: calc(100vh - 160rpx);" class="wid100" scroll-y="true" @scrolltolower="lower">
			<view class="hei20"></view>
			<view class="wid90 mar fowe600 foSi30">我的发布</view>
			<wsj v-if="list.length == 0" zs='0'></wsj>
			<view class="wid90 mar dis disAl disJuB flwa">
				<block v-for="(item,index) in list" :key="index">
					<view class="borRad10 bacFFF mar-top30 poRel" @click="xiangqing(item)"
						style="width: 48%;overflow: hidden;">
						<image :src="item.trends_coverimg" class="wid100" style="height: 320rpx;"></image>
						<image v-if="item.type == '视频'" :lazy-load="true" src="../../../static/bofang.png" class="poAbs"
							style="z-index: 1;width: 62rpx;height: 62rpx;top: 109rpx;left: 124rpx;"></image>
						<view class="wid90 mar mar-top10">
							<view class="foSi25 fowe600" style="line-height: 40rpx;">{{item.title}}</view>
							<view class="dis disAl disJuB mar-top10">
								<view class="dis disAl">
									<image :lazy-load="true" :src="item.coverimg" style="width: 34rpx;height: 34rpx;" class="borRad50 mar-right10"></image>
									<view class="foSi18 fowe600">{{item.name}}</view>
								</view>
								<view class="dis disAl">
									<uni-icons type="location-filled" size="25rpx" :color="theme.main_color"></uni-icons>
									<view class="foSi15 mar-left10">{{item.km}}</view>
								</view>
							</view>
						</view>
						<view style="height: 20rpx;"></view>
					</view>
				</block>
			</view>
			<view style="height: 50rpx;"></view>
		</scroll-view>
		<view class="poFix dis disAl disJuC borRad50" @click="tiaozhuan('/pages/dynamically/video')"
			:style="'background-color: '+theme.main_color+';'" style="height: 100rpx;width: 100rpx;bottom: 20%;right: 20rpx;z-index: 10;">
			<view>
				<view class="mar" style="width: 30rpx;height: 30rpx;">
					<image src="../../../static/pinglun1.png" class="wh100"></image>
				</view>
				<view class="textCen coFFF foSi20 mar-top10">发布</view>
			</view>
		</view>
	</view>
</template>

<script>
	import wsj from '../../common/w_sj.vue'
	export default {
		components: {
			wsj
		},
		data() {
			return {
				url: this.global.url,
				last_page: 0,
				page: 1,
				list: [],
				weidu: null,
				theme: null
			}
		},
		onLoad() {
			this.theme = uni.getStorageSync('theme')
		},
		onShow(){
			this.page = 1
			this.getList()
			this.getWeidu()
		},
		methods: {
			getWeidu(){
				var that = this;
				uni.request({
					url: that.global.url + 'api/qianyu_smfw/trends/unread',
					method: "POST",
					header: {
						'site-id': that.global.site_id ,//自定义请求头信息
						'token': uni.getStorageSync('token')
					},
					data: {},
					success(res) {
						let result = res.data
						if (result.code == 1) {
							that.weidu = result.data
						}else{
							uni.showToast({
								title: result.msg,
								//将值设置为 success 或者直接不用写icon这个参数
								icon: 'error',
								//显示持续时间为 2秒
								duration: 2000
							}) 
						}
					}
				})
			},
			getList(){
				var that = this;
				uni.request({
					url: that.global.url + 'api/qianyu_smfw/trends/mylist',
					method: "POST",
					header: {
						'site-id': that.global.site_id ,//自定义请求头信息
						'token': uni.getStorageSync('token')
					},
					data: {
						lon: uni.getStorageSync('lon')?uni.getStorageSync('lon'):125.35043,
						lat: uni.getStorageSync('lat')?uni.getStorageSync('lat'):43.86414,
						page: that.page
					},
					success(res) {
						let result = res.data
						if (result.code == 1) {
							that.last_page = result.data.last_page
							if(that.page == 1){
								that.list = result.data.data
							}else{
								that.list = that.list.concat(result.data.data)
							}
						}else{
							uni.showToast({
								title: result.msg,
								//将值设置为 success 或者直接不用写icon这个参数
								icon: 'error',
								//显示持续时间为 2秒
								duration: 2000
							}) 
						}
					}
				})
			},
			xiangqing(item){
				var that = this
				if(item.type == '图片'){
					that.tiaozhuan('/pages/dynamically/pictureParticulars?id='+item.id)
				}else{
					that.tiaozhuan('/pages/dynamically/videoParticulars?id='+item.id)
				}
			},
			lower(e) {
				if(this.last_page > this.page){
					this.page++
					this.getList()
				}
			},
			tiaozhuan(url) {
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style>
	.content {
		min-height: 100vh;
		background-color: #F3F1F1;
	}
</style>